package ca.scotthyndman.web.swf.common;

/**
 * Represents an ActionScript class file.
 * 
 * @author Scott Hyndman
 */
public class Class {

	protected String name;

	protected Package parent;

	protected boolean isPacked = false;

	/**
	 * Constructs a new class.
	 * 
	 * @param name
	 */
	public Class(String name) {
		this.name = name;
	}

	/**
	 * Gets the class' name.
	 * 
	 * @return The class name.
	 */
	public String getName() {
		return name;
	}

	/**
	 * Gets the parent package.
	 * 
	 * @return The class' enclosing package.
	 */
	public Package getParent() {
		return parent;
	}

	/**
	 * Returns whether the class is packed.
	 * 
	 * @return <code>true</code> if the class is packed.
	 */
	public boolean isPacked() {
		return isPacked;
	}

	/**
	 * Sets whether the class should be packed into the build.
	 * 
	 * @param isPacked
	 */
	public void setPacked(boolean isPacked) {
		this.isPacked = isPacked;
	}

	/**
	 * Gets the fully qualified package name.
	 * 
	 * @return The fully-qualified class name.
	 */
	public String getFullName() {
		if (parent == null) {
			return "";
		} else if (parent.parent == null) {
			return name;
		} else {
			return parent.getFullName() + "." + name;
		}
	}

	/**
	 * Returns a string representation of the object.
	 * 
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return getFullName();
	}
}
